import cv2
import numpy as np

cap = cv2.VideoCapture("rtsp://admin:admin12345@192.168.1.230:554/h264/ch43/sub/av_stream")


while cap.isOpened():
	ret,frame = cap.read()
	img = frame
	rows,cols,ch = img.shape
	print(img.shape)
	#变换前4点坐标
	pts1 = np.float32([[721,357],[883,387],[652,439],[830,478]])
	#变换后4点坐标
	pts2 = np.float32([[830,373],[830,483],[720,373],[720,483]])
	#计算变换矩阵
	M = cv2.getPerspectiveTransform(pts1,pts2)
	#应用到图像
	#TODO:图像位置调整
	dst = cv2.warpPerspective(img,M,(cols*2,rows),cv2.INTER_LINEAR)
	cv2.imshow('image',dst)
	cv2.waitKey(1)